package cn.com.dcsgo.model;

import cn.com.dcsgo.constant.EsConstant;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import org.springframework.data.elasticsearch.annotations.Setting;

import java.math.BigDecimal;
import java.util.List;

/**
 * 商品检索对象
 *
 * @author Dcsgo
 * @since 2025/10/24 10:04
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Document(indexName = EsConstant.PROD_ES_INDEX, createIndex = false)
@Setting(shards = 2, replicas = 0, refreshInterval = "-1")
@Schema(description = "商品检索对象")
public class ProdEs {
    /**
     * 产品ID
     */
    @Schema(description = "产品ID")
    @Id//将prodId与ES自动生成的ID进行关联
    @Field(type = FieldType.Long)
    private Long prodId;

    /**
     * 商品名称
     */
    @Schema(description = "商品名称")
    @Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_smart")
    private String prodName;

    /**
     * 店铺id
     */
    @Schema(description = "店铺id")
    @Field(type = FieldType.Long)
    private Long shopId;

    /**
     * 现价
     */
    @Schema(description = "现价")
    @Field(type = FieldType.Double)
    private BigDecimal price;

    /**
     * 简要描述（例如商品卖点）
     */
    @Schema(description = "简要描述（例如商品卖点）")
    @Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_smart")
    private String brief;

    /**
     * 商品主图
     */
    @Schema(description = "商品主图")
    @Field(type = FieldType.Text)
    private String pic;

    /**
     * 商品分类ID
     */
    @Schema(description = "商品分类ID")
    @Field(type = FieldType.Long)
    private Long categoryId;

    /**
     * 销量
     */
    @Schema(description = "销量")
    @Field(type = FieldType.Integer)
    private Integer soldNum;

    /**
     * 商品活动ID
     */
    @Schema(title = "商品活动ID")
    @Field(type = FieldType.Long)
    private List<Long> tagList;

    /**
     * 好评率
     */
    @Schema(title = "好评率")
    @Field(type = FieldType.Double)
    private BigDecimal positiveRating = BigDecimal.ZERO;

    /**
     * 好评数
     */
    @Schema(title = "好评数")
    @Field(type = FieldType.Long)
    private Long praiseNumber = 0L;
}
